package LuoGu.蛇形方阵;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int [][] ans = new int[n][n];
        int top = 0, left = 0, button = n, right = n;
        int all = 1;
        while(all<=n*n){
            for(int i = left;i<right;i++){
                ans[top][i] = all;
                all++;
            }
            top++;
            for(int i = top;i<button;i++){
                ans[i][right-1] = all;
                all++;
            }
            right--;
            for(int i = right-1;i>=left;i--){
                ans[button-1][i] = all;
                all++;
            }
            button--;
            for(int i = button-1;i>=top;i--){
                ans[i][left] = all;
                all++;
            }
            left++;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                System.out.printf("%3d",ans[i][j]);
            }
            System.out.println();
        }
    }
}
